<!--
 * @Author: GL
 * @Date: 2022-09-20 17:04:32
 * @LastEditors: GL
 * @LastEditTime: 2022-09-23 00:02:32
 * @Description: 注册
-->
<template>
  <div class="login">
    <el-form class="login-form" label-width="60px">
      <h3 class="title">大蓉子后台管理系统</h3>
      <el-form-item label="用户名">
        <el-input
          v-model="registerData.name"
          type="text"
          placeholder="请输入用户名"
        ></el-input>
      </el-form-item>
      <el-form-item label="密码">
        <el-input
          v-model="registerData.passwd"
          type="password"
          placeholder="请输入密码"
          show-password
        ></el-input>
      </el-form-item>
      <el-form-item label="性别">
        <el-input
          v-model="registerData.sex"
          type="sex"
          placeholder="请输入性别"
        ></el-input>
      </el-form-item>
      <el-button type="primary" size="default" class="btn" @click="register">注册</el-button>
    </el-form>
  </div>
</template>

<script>
// @ is an alias to /src
import { userRegister } from "../network/user.js";
export default {  
  name: "register",
  data() {
    return {
      registerData: {
        name: "",
        passwd: "",
        sex:"",
        phone: "17789424151",
      },
    };
  },
  components: {},
  methods:{
    register() {
      userRegister(this.registerData.name,this.registerData.passwd,this.registerData.sex,this.registerData.phone)
      .then(res => {
        if (res.status == 0) {
          this.$message({
            message: res.msg,
            type: 'success'
          });
          this.$router.push('/login')
        } else {
          this.$message({
            message: res.msg,
            type: 'warning'
          })
        }
      })
      .catch(err => {
        console.log(err);
      })
    }
  }
};
</script>
<style lang="scss" scoped>
.login{
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  background-image: url("../assets/background.webp");
  background-size: cover;
  .login-form{
    background-color: #FFFFFF;
    border-radius: 6px;
    padding: 25px 25px 5px 25px;
    width: 25%;
    height: 40%;
    line-height: 48px;
    .title {
      margin: 0px auto 30px auto;
      text-align: center;
      color: #707070;
    }
    .btn{
      width: 100%;
    }
    .register{
      display: flex;
      justify-content: flex-end;
      font-size: 13px;
      color:  #79bbff;
    }
  }
}
</style>
